package com.czzapp.xiaoyumemo.model;

import java.util.Date;

public class Memo implements Comparable<Memo> {
	public enum MemoState {
		Coming,
		Missed,
		Gone;
		public static MemoState intToMemoState(int state) {
			switch(state) {
			case 0:
				return Coming;
			case 1:
				return Missed;
			case 2:
				return Gone;
			default:
				return Coming;
			}
		}
		public int toInt() {
			switch(this) {
			case Coming:
				return 0;
			case Missed:
				return 1;
			case Gone:
				return 2;
			default:
				return 0;
			}
		}
	}
	
	private int mId;
	private String mTitle;
	private String mContent;
	//绝对路径
	private String mAudioPath;
	//初始设定的日期
	private Date mInitDate;
	//预计提醒的日期
	private Date mDelayDate;
	private MemoState mState;
	
	Memo(int id, String title, String content, String audioPath, Date initDate, Date delayDate, MemoState state) {
		mId = id;
		mTitle = title;
		mContent = content;
		mAudioPath = audioPath;
		mInitDate = initDate;
		mDelayDate = delayDate;
		mState = state;
	}
	
	@Override
	//如果日期相同，那么以reqId来比较
	public int compareTo(Memo another) {
		int delayDateCompareResult = mDelayDate.compareTo(another.getDelayDate());
		if(delayDateCompareResult != 0) {
			return delayDateCompareResult;
		}
		else {
			long temp = mId - another.getId();
			if(temp > 0) {
				return 1;
			}
			else if(temp < 0) {
				return -1;
			}
			else {
				return 0;
			}
		}
	}
	
	public int getId() {
		return mId;
	}
	
	void setId(int id) {
		mId = id;
	}
	
	public String getTitle() {
		return mTitle;
	}
	
	public void setTitle(String title) {
		mTitle = title;
	}
	
	public String getContent() {
		return mContent;
	}
	
	public void setContent(String content) {
		mContent = content;
	}
	
	public String getAudioPath() {
		return mAudioPath;
	}
	
	public void setAudioPath(String audioPath) {
		mAudioPath = audioPath;
	}
	
	public Date getInitdate() {
		return mInitDate;
	}
	
	public void setInitDate(Date initDate) {
		mInitDate = initDate;
	}
	
	public Date getDelayDate() {
		return mDelayDate;
	}
	
	void setDelayDate(Date delayDate) {
		mDelayDate = delayDate;
	}
	
	void check() {
		mState = MemoState.Gone;
	}
	
	void miss() {
		mState = MemoState.Missed;
	}
	
	public MemoState getState() {
		return mState;
	}
}
